
<?php
function shorten($resume){
	
	$wc = strlen($resume);
	$charLimit = 300;
	$index=0;
	$insideCharLimit=TRUE;
	$lastSpacePosition=0;
	
	if ($wc > $charLimit){
		
		while($index < $wc && $insideCharLimit){
			
			$actualChar = $resume[$index];
			if($actualChar == " "){
				
				if($index > $charLimit){
					$insideCharLimit=FALSE;
				}
				else{
					$lastSpacePosition = $index;
				}
				
			}
			$index++;
		
		}
		
		$shortenResume =substr($resume,0,$lastSpacePosition) . " ...";
	
		
	}
	else{
		$shortenResume = $resume;
	}
	
	return($shortenResume);

}
?>
